//define serialize/deserialize data types
#ifndef __PERSISTENT_TYPES_H__
#define __PERSISTENT_TYPES_H__

#include <vector>
#include "Archive.h"

class SCoordinate
{
	friend class Archive;
public:
	double m_x;
	double m_y;
private:
	void Serialize(Archive& ar);
};

class Attribute
{
	friend class Archive;
public:
	std::string m_strName;
	std::string m_strValue;
private:
	void Serialize(Archive& ar);
};

template<typename T>
class List
{
	friend class Archive;
public:
	std::vector<T>	m_List;
private:
	void Serialize(Archive& ar);
};

class AttributeList
{
	friend class Archive;
public:
	List<Attribute>	m_AttributeList;
private:
	void Serialize(Archive& ar);
};

class LinkRecord
{
	friend class Archive;
public:
	unsigned short	m_size;
	unsigned char	m_type;
	std::string		m_strId;
	AttributeList	m_commonAttribute;
	AttributeList	m_uncommonAttribute;
private:
	void Serialize(Archive& ar);
};

class NodeRecord
{
	friend class Archive;
public:
	unsigned int		m_size;
	unsigned int		m_linkTableOffset;
	unsigned int		m_coordinateTableOffset;
	unsigned char		m_level;
	List<LinkRecord>	m_linkTable;
private:
	void Serialize(Archive& ar);
};

class Envelop
{
	friend class Archive;
public:
	SCoordinate		m_topLeft;
	SCoordinate		m_buttomRight;
private:
	void Serizlize(Archive& ar);
};

class GridRecord
{
	friend class Archive;
public:
	Envelop			m_bandHull;
	unsigned int	m_nodeRecordOffset;
	unsigned int	m_nodeCount;
private;
	void Serialize(Archive& ar);
};

class RegionFrame
{
	friend class Archive;
public:
	Envelop				m_bandHull;
	unsigned int		m_size;
	unsigned int		m_nodeCount;
	List<GridRecord>	m_gridTable;
	unsigned int		m_nodeTableOffset;
private:
	void Serialize(Archive& ar);
};

class RegionHeader
{
	friend class Archive;
public;
	Envelop			m_bandHull;
	unsigned int	m_regionCount;
private:
	void Serialize(Archive& ar);
};
#endif